package handler

import (
	"github.com/gin-gonic/gin"
	"tdmanage3/models"
)

func Add(c *gin.Context) {
	name := c.PostForm("name")
	Content := c.PostForm("content")
	role := models.Role{
		Name:    name,
		Content: Content,
	}
	err := models.DB.Create(&role).Error
	if err != nil {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  "添加失败",
		})
		return
	}
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "添加成功",
	})
	return
}
func QxAdd(c *gin.Context) {
	name := c.PostForm("name")
	qx := models.Qx{
		Name: name,
	}
	err := models.DB.Create(&qx).Error
	if err != nil {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  "添加失败",
		})
		return
	}
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "添加成功",
	})
	return
}
